home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / CAPITAL.AML < prev    next >
Text File  |  1996-07-17  |  1KB  |  53 lines

  1. //--------------------------------------------------------------------
  2. // CAPITAL.AML
  3. // Capitalize Words, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro capitalizes words in a marked block. If no block is
  6. // marked, then words are capitalized in the current line.
  7. //
  8. // The CSet configuration variable is used to define a word for this
  9. // macro.
  10. //
  11. // Usage:
  12. //
  13. // Select this macro from the Macro List (on the Macro menu), or run it
  14. // from the macro picklist <shift f12>.
  15. //--------------------------------------------------------------------
  16.  
  17. // compile time macros and function definitions
  18. include bootpath "define.aml"
  19.  
  20. // test for edit windows
  21. if not wintype? "edit" then
  22.   msgbox "Edit windows only!"
  23.   return
  24. end
  25.  
  26. // use CSet variable for word character set
  27. pattern = '[' + _CSet + ']#'
  28.  
  29. // test if a marked block exists in the current file
  30. options = if mark? and getmarkbuf == getcurrbuf then
  31.             "xb"
  32.           else
  33.             "xl"
  34.           end
  35.  
  36. // save cursor position and start undo group
  37. pushcursor
  38. undobegin
  39.  
  40. // find first word
  41. wordsize = find pattern options + "*g"
  42. while wordsize do
  43.   // capitalize word
  44.   text = gettext (getcol) wordsize
  45.   ovltext (concat (upcase text [1]) (locase (text [2..TO_END])))
  46.   right wordsize
  47.   // find next word
  48.   wordsize = find pattern options
  49. end
  50.  
  51. undoend
  52. popcursor
  53.